package actions;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.ejb.EJB;

import beans.UserManager;
import beans.UserManagerLocal;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import entities.User;

public class ModifyFriendsAction extends ActionSupport {

	@EJB
	private UserManagerLocal userMgr = new UserManager();
	
	private ArrayList<User> resultList;
	private ArrayList<User> resultAFList;
	
	
	public String execute() {
		
		Map session = ActionContext.getContext().getSession();
		Integer id = (Integer) session.get("userId");

		if (id == null) {
			return ERROR;
		} else {
			// Get list of friends and antifriends
			resultList   = (ArrayList<User>)userMgr.getFriends(id);
			resultAFList = (ArrayList<User>)userMgr.getAntifriends(id);
		}

		return SUCCESS;
	}

	public ArrayList<User> getResultList() {
		return resultList;
	}

	public void setResultList(ArrayList<User> resultList) {
		this.resultList = resultList;
	}

	public ArrayList<User> getResultAFList() {
		return resultAFList;
	}

	public void setResultAFList(ArrayList<User> resultAFList) {
		this.resultAFList = resultAFList;
	}

}
